Ext.define('Util.Auth', {});
window.Auth =
{
    username : "[UKNOWN]",
    organization : "[UKNOWN]",

    checkAuthentication : function(callback)
    {
        var me = this;
        Backend.request(Backend.GET, "/", {},
        {
            success : function(resp)
            {
            	debugger
                var cookie = Ext.util.Cookies.get("userSession");
                if (!cookie)
                    return;
                var session = Ext.decode(cookie);
                if (!session)
                    return;
                if (session.contact)
                {
                    me.username = session.contact.firstName + " " + session.contact.lastName;
                } else
                {
                    me.username = session.name;
                }
                var _callback = undefined;
                if (undefined != callback)
                {
                    _callback = callback.afterAutorization;
                }
            },
            failure : function(resp)
            {
            	debugger
                //                me.logout();
                window.location = "login?redirectURL=/";
            }
        });
    },

    logout : function()
    {
    //        IdleTimer.stop();
    //        Backend.logout();
    }

};